<template>
  <div class="dashboard-container">
    <!-- 顶部标题 -->
    <div class="dashboard-header">
      <div class="title">智慧物业数据可视化大屏</div>
      <div class="time">{{ currentTime }}</div>
      <div class="weather">{{ temperature }}℃</div>
    </div>

    <!-- 主要内容区域 -->
    <div class="dashboard-content">
      <!-- 左侧面板 -->
      <div class="left-panel panel">
        <div class="panel-title">业主扫入情况</div>
        <div class="data-list">
          <div class="data-item">
            <div class="label">用户总数</div>
            <div class="value">1356</div>
          </div>
          <div class="data-item">
            <div class="label">认证用户</div>
            <div class="value">1300</div>
          </div>
          <div class="data-item">
            <div class="label">平台增长</div>
            <div class="value">56</div>
          </div>
          <div class="data-item">
            <div class="label">管理人员</div>
            <div class="value">56</div>
          </div>
        </div>
      </div>

      <!-- 中间区域 -->
      <div class="center-panel">
        <!-- 顶部数据卡片 -->
        <div class="data-cards">
          <div class="card">
            <div class="label">房屋数</div>
            <div class="value">447</div>
          </div>
          <div class="card">
            <div class="label">注册用户</div>
            <div class="value">355</div>
          </div>
          <div class="card">
            <div class="label">今日收益</div>
            <div class="value">478元</div>
          </div>
          <div class="card">
            <div class="label">本月收益</div>
            <div class="value">589元</div>
          </div>
          <div class="card">
            <div class="label">日均交易</div>
            <div class="value">487元</div>
          </div>
        </div>

        <!-- 物业收费金额统计图表 -->
        <div class="chart-container">
          <div class="chart-title">物业收费金额统计</div>
          <div class="chart" ref="propertyFeeChart"></div>
        </div>

        <!-- APP使用情况统计 -->
        <div class="chart-container">
          <div class="chart-title">APP使用情况统计</div>
          <div class="chart" ref="appUsageChart"></div>
        </div>
      </div>

      <!-- 右侧面板 -->
      <div class="right-panel panel">
        <div class="panel-title">工单状态</div>
        <div class="pie-chart" ref="workOrderChart"></div>
        
        <div class="panel-title">工单排名</div>
        <div class="ranking-chart" ref="rankingChart"></div>
        
        <div class="panel-title">监控画面</div>
        <div class="monitor-grid">
          <div class="monitor-item" v-for="i in 4" :key="i">
            <img :src="require('@/assets/monitor-' + i + '.jpg')" alt="监控画面">
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  name: 'Dashboard',
  data() {
    return {
      currentTime: '',
      temperature: '16.5',
      timer: null
    }
  },
  mounted() {
    this.initCharts()
    this.startTimer()
  },
  beforeDestroy() {
    if (this.timer) {
      clearInterval(this.timer)
    }
  },
  methods: {
    startTimer() {
      this.updateTime()
      this.timer = setInterval(this.updateTime, 1000)
    },
    updateTime() {
      const now = new Date()
      this.currentTime = now.toLocaleString('zh-CN', {
        hour12: false,
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
        hour: '2-digit',
        minute: '2-digit',
        second: '2-digit'
      }).replace(/\//g, '-')
    },
    initCharts() {
      // 初始化物业收费金额统计图表
      const propertyFeeChart = echarts.init(this.$refs.propertyFeeChart)
      propertyFeeChart.setOption({
        // 配置省略...
      })

      // 初始化工单状态饼图
      const workOrderChart = echarts.init(this.$refs.workOrderChart)
      workOrderChart.setOption({
        // 配置省略...
      })

      // 其他图表初始化...
    }
  }
}
</script>

<style scoped>
.dashboard-container {
  width: 100%;
  height: 100vh;
  background: #001529;
  color: #fff;
  padding: 20px;
  box-sizing: border-box;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 50px;
  height: 60px;
}

.title {
  font-size: 32px;
  font-weight: bold;
  background: linear-gradient(to right, #fff, #7ACDCB);
  -webkit-background-clip: text;
  color: transparent;
}

.dashboard-content {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  height: calc(100% - 80px);
}

.panel {
  background: rgba(6, 30, 93, 0.5);
  border-radius: 4px;
  padding: 20px;
}

.left-panel {
  width: 25%;
}

.center-panel {
  width: 48%;
}

.right-panel {
  width: 25%;
}

.data-cards {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card {
  background: rgba(6, 30, 93, 0.7);
  padding: 15px;
  border-radius: 4px;
  text-align: center;
}

.chart-container {
  background: rgba(6, 30, 93, 0.5);
  margin-bottom: 20px;
  padding: 20px;
  border-radius: 4px;
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.monitor-item {
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}

.monitor-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 添加更多样式... */
</style> 